import { Component } from 'react'
import { Provider } from 'mobx-react'
import MainList from '../MainList'
import { getInitList } from '../../../utils'

export default class ListPage extends Component {
  static async getInitialProps ({ pathname }) {
    const path = '福利'
    const apiUrl = `https://gank.io/api/data/${encodeURIComponent(path)}/20`
    const initList = await getInitList(apiUrl)

    return {
      path,
      apiUrl,
      initList
    }
  }

  render () {
    const { props } = this

    return (
      <Provider store={this.store}>
        <MainList title={props.path} apiUrl={props.apiUrl} />
      </Provider>
    )
  }
}
